﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace ManageSystem
{
    public partial class ManageForm : Form


    {
        ManageStuff userList;
        ManageBook manageBook;
        ManageBookType manageType;
        BorrowBook borrowBook;

        public ManageForm()
        {
            InitializeComponent();
        }

        public ManageForm(string userId, string userName)
        {
            InitializeComponent();
            UserId.Text = userId;
            UserName.Text = userName;

        }

        private void statusStrip1_ItemClicked(object sender, ToolStripItemClickedEventArgs e)
        {

        }

        private void menuStrip1_ItemClicked(object sender, ToolStripItemClickedEventArgs e)
        {

        }

        private void ManageForm_Load(object sender, EventArgs e)
        {
            this.toolStripStatusLabel3.Text = DateTime.Now.ToString("yyyy-MM-dd hh:mm:ss");
            this.timer.Interval = 1000;
            this.timer.Start();

            //userList = new ManageStuff();
            //userList.FormBorderStyle = FormBorderStyle.None;
            //userList.Dock = DockStyle.Fill;
            //userList.TopLevel = false;

            //this.panel1.Controls.Clear();
            //this.panel1.Controls.Add(userList);
            ////obj.MdiParent = this;
            //userList.Show();
        }



        private void toolStripStatusLabel2_Click(object sender, EventArgs e)
        {

        }

        private void toolStripStatusLabel3_Click(object sender, EventArgs e)
        {

        }

        private void timer_Tick(object sender, EventArgs e)
        {
            this.toolStripStatusLabel3.Text = DateTime.Now.ToString("yyyy-MM-dd hh:mm:ss");
        }

        private void 员工管理ToolStripMenuItem_Click(object sender, EventArgs e)
        {
            if (borrowBook == null)
            {
                borrowBook = new BorrowBook();
                borrowBook.FormBorderStyle = FormBorderStyle.None;
                borrowBook.Dock = DockStyle.Fill;
                borrowBook.TopLevel = false;
            }
            this.panel1.Controls.Clear();
            this.panel1.Controls.Add(borrowBook);
            //obj.MdiParent = this;
            borrowBook.Show();
        }

        private void 工资管理ToolStripMenuItem_Click(object sender, EventArgs e)
        {

        }

        private void 浏览用户ToolStripMenuItem_Click(object sender, EventArgs e)
        {

        }

        private void 管理用户ToolStripMenuItem_Click(object sender, EventArgs e)
        {
            if (userList == null)
            {
                userList = new ManageStuff();
                userList.FormBorderStyle = FormBorderStyle.None;
                userList.Dock = DockStyle.Fill;
                userList.TopLevel = false;
            }
            this.panel1.Controls.Clear();
            this.panel1.Controls.Add(userList);
            //obj.MdiParent = this;
            userList.Show();
        }

        private void 管理图书ToolStripMenuItem_Click(object sender, EventArgs e)
        {
            if (manageBook == null)
            {
                manageBook = new ManageBook();
                manageBook.FormBorderStyle = FormBorderStyle.None;
                manageBook.Dock = DockStyle.Fill;
                manageBook.TopLevel = false;
            }
            this.panel1.Controls.Clear();
            this.panel1.Controls.Add(manageBook);
            //obj.MdiParent = this;
            manageBook.Show();
        }

        private void 管理图书分类ToolStripMenuItem_Click(object sender, EventArgs e)
        {
            if (manageType == null)
            {
                manageType = new ManageBookType();
                manageType.FormBorderStyle = FormBorderStyle.None;
                manageType.Dock = DockStyle.Fill;
                manageType.TopLevel = false;
            }
            this.panel1.Controls.Clear();
            this.panel1.Controls.Add(manageType);
            //obj.MdiParent = this;
            manageType.Show();
        }

        private void 退出登陆ToolStripMenuItem_Click(object sender, EventArgs e)
        {
            if (MessageBox.Show("确定要退出登陆？", "提示", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == System.Windows.Forms.DialogResult.Yes)
            {

                LoginForm login = (LoginForm)this.Owner;
                login.Show();
                this.Hide();

            }
        }

        private void 管理用户ToolStripMenuItem_Click_1(object sender, EventArgs e)
        {
            if (userList == null)
            {
                userList = new ManageStuff();
                userList.FormBorderStyle = FormBorderStyle.None;
                userList.Dock = DockStyle.Fill;
                userList.TopLevel = false;
            }
            this.panel1.Controls.Clear();
            this.panel1.Controls.Add(userList);
            //obj.MdiParent = this;
            userList.Show();
        }

        private void 修改密码ToolStripMenuItem_Click(object sender, EventArgs e)
        {
            ChangePwd change = new ChangePwd(UserId.Text);
            change.Show();
        }

        void Form1_FormClosing(object sender, FormClosingEventArgs e)
        {
            if (MessageBox.Show("确定要退出系统么?", "提示", MessageBoxButtons.OKCancel, MessageBoxIcon.Question) == DialogResult.OK)

            {

                Application.Exit();
                return;
            }
        }
    }
}
